package com.chensi.util;

import java.io.UnsupportedEncodingException;

import org.apache.commons.lang3.StringUtils;

public class PropertiesUtil {

	private PropertiesUtil() {
	}

	private static PropertiesUtil instance = null;

	public synchronized static PropertiesUtil getInstance() {
		if (instance == null)
			instance = new PropertiesUtil();
		return instance;
	}

	private static PropertiesLoader propertiesLoader = new PropertiesLoader("config.properties");

	public static String getProperty(String key) {
		try {
			String value = propertiesLoader.getProperty(key);
			if(StringUtils.isNotEmpty(value)){
				return new String(value.getBytes("iso8859-1"), "utf-8");
			}
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return "";
	}
}
